import {
  getPhysicalStockListService,
  getSaleOccListService,
  getOnWayOrderListService
} from '@/api/commodity/common';

// 实物库存数
export const REAL_STOCK_NUM_COLUMNS = [
  {
    title: '分公司',
    key: 'companyName',
  },
  {
    title: '库存',
    key: 'totalStockQty',
  },
  {
    title: '占用库存',
    key: 'occupiedStockQty',
  },
  {
    title: '可用库存',
    key: 'availableStockQty',
  }
]

// 采购在途数
export const PURCHASE_STOCK_NUM_COLUMNS = [
  {
    title: '订单号',
    key: 'orderNo',
  },
  {
    title: '在途数量',
    key: 'onWayStock',
  },
  {
    title: '制单人',
    key: 'maker',
  },
  {
    title: '制单公司',
    key: 'makerCompany',
  }
]

// 销售占用数
export const REAL_STOCK_OCCUPY_COLUMNS = [
  {
    title: '订单号',
    key: 'orderNo',
  },
  {
    title: '占用数量',
    key: 'occupyQty',
  },
  {
    title: '制单人',
    key: 'maker',
  },
  {
    title: '制单公司',
    key: 'makerCompany',
  }
]

// 转货在途数
export const TRANSSHIP_STOCK_NUM_COLUMNS = [
  {
    title: '订单号',
    key: 'orderNo',
  },
  {
    title: '在途数量',
    key: 'onWayStock',
  },
  {
    title: '制单人',
    key: 'maker',
  },
  {
    title: '制单公司',
    key: 'makerCompany',
  }
]

export const STOCK_MAPPING_KEYS = {
  REAL_NUM: 'allRealStockNum',
  PURCHASE_NUM: 'allPurchaseStockNum',
  REAL_OCCUPY: 'allRealStockOccupy',
  TRANSSHIP_NUM: 'allTransshipStockNum'
}

// businessType 1, "采购订单" 2, "转货订单"

const REAL_NUM_OPTION = {
  method: getPhysicalStockListService,
  title: '全集团实物库存数',
  columns: REAL_STOCK_NUM_COLUMNS,
  businessType: 1
}

const PURCHASE_NUM_OPTION = {
  method: getOnWayOrderListService,
  title: '全集团采购在途数',
  columns: PURCHASE_STOCK_NUM_COLUMNS,
  businessType: 1
}

const REAL_OCCUPY_OPTION = {
  method: getSaleOccListService,
  title: '全集团销售占用数',
  columns: REAL_STOCK_OCCUPY_COLUMNS
}

const TRANSSHIP_NUM_OPTION = {
  method: getOnWayOrderListService,
  title: '全集团转货在途数',
  columns: TRANSSHIP_STOCK_NUM_COLUMNS,
  businessType: 2
}

export const STOCK_RELATIVE_OPTIONS = {
  [STOCK_MAPPING_KEYS.REAL_NUM]: REAL_NUM_OPTION,
  [STOCK_MAPPING_KEYS.PURCHASE_NUM]: PURCHASE_NUM_OPTION,
  [STOCK_MAPPING_KEYS.REAL_OCCUPY]: REAL_OCCUPY_OPTION,
  [STOCK_MAPPING_KEYS.TRANSSHIP_NUM]: TRANSSHIP_NUM_OPTION,
}
